<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>省生态委考核数据分析</title>
    <link href="lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="lib/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="lib/website/tb-page.css" rel="stylesheet">
    <style type="text/css">
    .form-horizontal .control-label {
        text-align: left;
    }
    </style>
</head>

<body>
    <div class="container-fluid">
        <div class="row header">
            <div class="col-md-8 col-sm-8">
                <h3>辽宁环保攻坚考核系统</h3>
            </div>
            <div class="col-md-4 col-sm-4 ">
                <h6 class="text-right">欢迎您! XX管理员@XXX.com</h6>
            </div>
        </div>
        <div class="row">
            <nav class="navbar navbar-default">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-top">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">辽宁环保攻坚考核系统</a>
                </div>
                <div class="collapse navbar-collapse" id="navbar-top">
                    <ul class="nav navbar-nav">
                        <li><a href="index.html">考核结果</a></li>
                        <li><a href="assess-department.html">考核评分</a></li>
                        <li><a href="assessed.html">数据上报</a></li>
                        <li class="active"><a href="dataAnalysis.html">数据分析</a></li>
                        <li><a href="userCenter.html">用户管理</a></li>
                    </ul>
                </div>
            </nav>
        </div>
        <div class="content">
            <div class="row">
                <div class="col-md-12">
                    <form class="form-horizontal">
                        <fieldset>
                            <div class="form-group">
                                <div class="col-md-2">
                                    <label for="inputEmail" class="control-label"><i class="glyphicon glyphicon-play text-primary"></i> 考核大类</label>
                                </div>
                                <div class="col-md-11">
                                    <div class="checkbox">
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="大气污染防治"> 大气污染防治</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="水污染防治"> 水污染防治</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="土壤污染防治"> 土壤污染防治</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="农业农村污染治理"> 农业农村污染治理</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="主要污染物减排"> 主要污染物减排</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="生态红线和自然保护区"> 生态红线和自然保护区</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="环境风险和信访办理"> 环境风险和信访办理</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="生态环境治理"> 生态环境治理</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="执法队伍和执法工作"> 执法队伍和执法工作</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="生态制度建设和保护责任落实"> 生态制度建设和保护责任落实</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort" value="近岸海域综合治理"> 近岸海域综合治理</label>&nbsp;&nbsp;
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-2">
                                    <label for="inputEmail" class="control-label"><i class="glyphicon glyphicon-play text-primary"></i> 被考核单位</label>
                                </div>
                                <div class="col-md-11">
                                    <div class="checkbox">
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="shenyangshi"> 沈阳市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="dalianshi"> 大连市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="anshanshi"> 鞍山市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="fushunshi"> 抚顺市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="benxishi"> 本溪市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="dandongshi"> 丹东市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="jinzhoushi"> 锦州市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="yingkoushi"> 营口市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="fuxinshi"> 阜新市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="liaoyangshi"> 辽阳市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="tielingshi"> 铁岭市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="chaoyangshi"> 朝阳市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="panjinshi"> 盘锦市</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="huludaoshi"> 葫芦岛市</label>&nbsp;&nbsp;
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-2">
                                    <label for="inputEmail" class="control-label"><i class="glyphicon glyphicon-play text-primary"></i> 牵头考核部门</label>
                                </div>
                                <div class="col-md-11">
                                    <div class="checkbox">
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省环保厅"> 省环保厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省发改委"> 省发改委</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省住建厅"> 省住建厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省信工委"> 省信工委</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省工商局"> 省工商局</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省质监局"> 省质监局</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省交通厅"> 省交通厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省农委"> 省农委</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省国土资源厅"> 省国土资源厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省水利厅"> 省水利厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省财政厅"> 省财政厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省畜牧局"> 省畜牧局</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort2" value="省海洋与渔业厅"> 省海洋与渔业厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort3" value="大连海事局"> 大连海事局</label>&nbsp;&nbsp;
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
            <div class="row" id="toolbar">
                <div class="col-md-12">
                    <a href="#" class="btn btn-primary" id="download">下载</a>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <table class="table table-striped table-hover table-bordered" id="table">
                        <!--<thead>-->
                        <!--<tr>-->
                        <!--<th data-checkbox='true'></th>-->
                        <!--<th>考核大类</th>-->
                        <!--<th>重点任务</th>-->
                        <!--<th>考核指标</th>-->
                        <!--<th>牵头考核部门</th>-->
                        <!--<th>分值</th>-->
                        <!--<th>平均得分</th>-->
                        <!--<th>达标合格分数</th>-->
                        <!--<th>大连</th>-->
                        <!--<th>鞍山</th>-->
                        <!--</tr>-->
                        <!--</thead>-->
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="lib/jquery/jquery.1.10.2.min.js"></script>
<script src="lib/bootstrap/js/bootstrap.min.js"></script>
<script src="lib/bootstrap-table/bootstrap-table.min.js"></script>
<script src="lib/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="lib/website/function.js"></script>
<script src="lib/website/interface.js"></script>
<script>
/**
 * 获取复选框值
 * @param
 * @returns {*}
 */
function getCheckBoxVal() { //jquery获取所有选中的复选框的值 
    var checkValue = [];
    $(".checkbox-ex").find('input:checkbox').each(function() { //遍历所有复选框
        if ($(this).prop('checked') == true) {
            if (checkValue['tScoringTableNames']) {
                if ($(this).attr('class') == 'sort') {
                    checkValue['tScoringTableNames'] = checkValue['tScoringTableNames'] + ',' + $(this).val();
                }
            } else {
                if ($(this).attr('class') == 'sort') {
                    checkValue['tScoringTableNames'] = $(this).val();
                }
            }
            if (checkValue['areaName']) {
                if ($(this).attr('class') == 'sort1') {
                    checkValue['areaName'] = checkValue['areaName'] + ',' + $(this).val();
                }
            } else {
                if ($(this).attr('class') == 'sort1') {
                    checkValue['areaName'] = $(this).val();
                }
            }
            if (checkValue['leaderDepartmentNames']) {
                if ($(this).attr('class') == 'sort2') {
                    checkValue['leaderDepartmentNames'] = checkValue['leaderDepartmentNames'] + ',' + $(this).val();
                }

            } else {
                if ($(this).attr('class') == 'sort2') {
                    checkValue['leaderDepartmentNames'] = $(this).val();
                }

            }
        }
    });
    return checkValue;
}

function cityMap(city) {
    switch (city) {
        case 'shenyangshi':
            return '沈阳市';
            break;
        case 'dalianshi':
            return '大连市';
            break;
        case 'anshanshi':
            return '鞍山市';
            break;
        case 'fushunshi':
            return '抚顺市';
            break;
        case 'benxishi':
            return '本溪市';
            break;
        case 'dandongshi':
            return '丹东市';
            break;
        case 'jinzhoushi':
            return '锦州市';
            break;
        case 'yingkoushi':
            return '营口市';
            break;
        case 'fuxinshi':
            return '阜新市';
            break;
        case 'liaoyangshi':
            return '辽阳市';
            break;
        case 'tielingshi':
            return '铁岭市';
            break;
        case 'chaoyangshi':
            return '朝阳市';
            break;
        case 'panjinshi':
            return '盘锦市';
            break;
        case 'huludaoshi':
            return '葫芦岛市';
            break;

    }
}

/**
 * 链接参数
 * @param name
 * @param value
 * @param extent
 */
function creatUrl(name, value, extent) {
    if (value.hasOwnProperty(name)) {
        if (extent) {
            extent = extent + '&' + name + '=' + value[name];
        } else {
            extent = name + '=' + value[name];
        }
    }
    return extent;
}

function getList(a, b, c) {
    var colum = [{
            field: 'tScoringTableName',
            title: '考核大类'
        }, {
            field: 'taskName',
            title: '重点任务'
        }, {
            field: 'assessmentIndicatorsName',
            title: '考核指标'
        },
        {
            field: 'scoringMethodName',
            title: '备注'
        },
        {
            field: 'leaderDepartmentName',
            title: '牵头部门'
        }, {
            field: 'scoreMax',
            title: '分值'
        }, {
            field: 'avgScore',
            title: '平均得分'
        }, {
            field: 'agreeScroe',
            title: '达标合格分数'
        }
    ];
    if (a) {
        var strs = a.split(",");
        $.each(strs, function(key, value) {
            var newColum = {};
            newColum.field = value;
            newColum.title = cityMap(value);
            colum.push(newColum)
        })

    }
    $('#table').bootstrapTable({
        url: 'http://39.98.42.158/manage/getAnalysis', //请求后台的URL（*）
        method: 'post', //请求方式（*）
        //toolbar: '#toolbar',                //工具按钮用哪个容器
        striped: true, //是否显示行间隔色
        cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true, //是否显示分页（*）
        sortable: false, //是否启用排序
        sortOrder: "asc", //排序方式
        // queryParams: oTableInit.queryParams,//传递参数（*）
        sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1, //初始化加载第一页，默认第一页
        pageSize: 10, //每页的记录行数（*）
        pageList: [10, 25, 50, 100], //可供选择的每页的行数（*）
        search: false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        strictSearch: false,
        showColumns: false, //是否显示所有的列
        showRefresh: false, //是否显示刷新按钮
        minimumCountColumns: 2, //最少允许的列数
        clickToSelect: false, //是否启用点击选中行
        height: 500, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
        uniqueId: "ID", //每一行的唯一标识，一般为主键列
        showToggle: false, //是否显示详细视图和列表视图的切换按钮
        cardView: false, //是否显示详细视图
        detailView: false, //是否显示父子表
        dataType: 'json',
        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
        queryParams: function(params) {
            var queryData = {}; //如果没有额外的查询参数的话就新建一个空对象，如果有的话就先装你的查询参数
            //然后增加这两个
            queryData.pageNo = (params.offset / params.limit) + 1;
            queryData.pageSize = params.limit;
            if (a) { queryData.areaNames = a }
            if (b) { queryData.tScoringTableNames = b }
            if (c) { queryData.leaderDepartmentNames = c }
            return queryData; //这个就是向服务端传递的参数对象
        },
        responseHandler: function(res) {
            var result = [];
            if (res.code != 200) {
                return false;
            }
            var rows = res.data.rows
            if (!res.data.rows) {
                return false;
            }
            result['rows'] = rows
            result['total'] = res.data.totalRows
            return result;
        },
        smartDisplay: true,
        paginationLoop: true,
        striped: true,
        columns: colum,
    });
}
getList();
$(document).ready(function() {
    //复选框选中
    $('.checkbox-ex input').change(function() {
        var checkboxVal = getCheckBoxVal()
        $("#table").bootstrapTable('destroy');
        getList(checkboxVal['areaName'], checkboxVal['tScoringTableNames'], checkboxVal['leaderDepartmentNames'])
    })

    $("#download").click(function() {
        var checkboxVal = getCheckBoxVal()
        var extent = '';
        extent = creatUrl('areaName', checkboxVal, extent)
        extent = creatUrl('tScoringTableNames', checkboxVal, extent)
        extent = creatUrl('leaderDepartmentNames', checkboxVal, extent)
        $url = 'http://39.98.42.158/manage/downLoadAnalysis'
        if (extent) {
			//{add by wuguofang 20181205 for 解决url中文乱码问题 begin
			extent=encodeURI(extent);
			//add by wuguofang 20181205 for 解决url中文乱码问题 end}
            $url = $url + '?' + extent;
        }
        console.log($url)
        window.open($url)
    })

})
</script>

</html>